<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:jsf="http://xmlns.jcp.org/jsf">
    <h:head>
    </h:head>

    <h:body>
        <ui:composition template="/dataverse_template.xhtml">
            <ui:param name="thisPageTitle" value="#{bundle['dataverse.search.advancedSearch']} - #{AdvancedSearchPage.dataverse.name}"/>
            <ui:param name="pageTitle" value="#{thisPageTitle}"/>
            <ui:param name="dataverse" value="#{AdvancedSearchPage.dataverse}"/>
            <ui:param name="ownerId" value="#{DataversePage.ownerId}"/>
            <ui:define name="body">
                <f:metadata>
                    <f:viewAction action="#{dataverseSession.updateLocaleInViewRoot}"/>
                    <f:viewAction action="#{AdvancedSearchPage.init}"/>
                    <f:viewParam name="dataverseIdentifier" value="#{AdvancedSearchPage.dataverseIdentifier}"/>
                    <f:viewAction action="#{dataverseHeaderFragment.initBreadcrumbs(AdvancedSearchPage.dataverse, bundle['dataverse.search.advancedSearch'])}"/>
                </f:metadata>
                <!-- Search Panel -->
                <div class="panel-group">
                    <h:form id="advancedSearchForm">
                        <p:focus/>
                        <div class="button-block margin-bottom">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.find}" action="#{AdvancedSearchPage.find()}"/>
                        </div>
                        <div class="panel panel-default">
                            <div data-toggle="collapse" data-target="#panelCollapseDataversesFieldList" class="panel-heading">
                                <h:outputText value="#{bundle['advanced.search.header.dataverses']}"/> &#160;<span class="glyphicon glyphicon-chevron-up"/>
                            </div>
                            <div id="panelCollapseDataversesFieldList" class="panel-body form-horizontal collapse in">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        #{bundle.name}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['advanced.search.dataverses.name.tip']}"></span>
                                    </label>
                                    <div class="col-sm-6">
                                        <p:inputText id="dvFieldName" styleClass="form-control" value="#{AdvancedSearchPage.dvFieldName}"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        #{bundle.identifier}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.identifier.title']}"></span>
                                    </label>
                                    <div class="col-sm-6">
                                        <p:inputText id="dvFieldAlias" styleClass="form-control" value="#{AdvancedSearchPage.dvFieldAlias}"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        #{bundle.affiliation}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['advanced.search.dataverses.affiliation.tip']}"></span>
                                    </label>
                                    <div class="col-sm-6">
                                        <p:inputText id="dvFieldAffiliation" styleClass="form-control" value="#{AdvancedSearchPage.dvFieldAffiliation}"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        #{bundle.description}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['advanced.search.dataverses.description.tip']}"></span>
                                    </label>
                                    <div class="col-sm-6">
                                        <p:inputText id="dvFieldDescription" styleClass="form-control" value="#{AdvancedSearchPage.dvFieldDescription}"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        #{bundle.subject}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['advanced.search.dataverses.subject.tip']}"></span>
                                    </label>
                                    <div class="col-sm-6">
                                        <div class="ui-inputfield form-control select-scroll-block">
                                            <p:selectManyCheckbox value="#{AdvancedSearchPage.dvFieldSubject}" layout="pageDirection">
                                                <f:selectItems value="#{AdvancedSearchPage.dvFieldSubjectValues}" var="cvv"
                                                               itemLabel="#{cvv.localeStrValue}" itemValue="#{cvv.strValue}"/>
                                            </p:selectManyCheckbox>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <ui:repeat value="#{AdvancedSearchPage.metadataBlocks}" var="mdb" varStatus="status">
                            <div class="panel panel-default" jsf:rendered="#{not empty AdvancedSearchPage.metadataFieldMap.get(mdb.getId())}">
                                <div data-toggle="collapse" data-target="#panelCollapseCitationFieldList#{mdb.id}" class="panel-heading">
                                    <h:outputText value="#{bundle['advanced.search.header.datasets']}: #{mdb.localeDisplayName}"/> &#160;<span class="glyphicon #{status.first?'glyphicon-chevron-up':'glyphicon-chevron-down'}"/>
                                </div>
                                <div id="panelCollapseCitationFieldList#{mdb.id}" class="collapse #{status.first?'in':''} panel-body form-horizontal">
                                    <ui:repeat value="#{AdvancedSearchPage.metadataFieldMap.get(mdb.getId())}" var="item">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">
                                                #{item.displayName}
                                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{item.localeDescription}"></span>
                                            </label>
                                            <div class="col-sm-6">
                                                <p:inputText id="searchValue" styleClass="form-control" value="#{item.searchValue}" rendered="#{empty item.controlledVocabularyValues}"/>
                                                <div class="ui-inputfield form-control select-scroll-block" jsf:rendered="#{!empty item.controlledVocabularyValues}">
                                                    <p:selectManyCheckbox value="#{item.listValues}" layout="pageDirection">
                                                        <f:selectItems value="#{item.controlledVocabularyValues}" var="cvs"
                                                                       itemLabel="#{cvs.localeStrValue}" itemValue="#{cvs.strValue}"/>
                                                    </p:selectManyCheckbox>
                                                </div>
                                            </div>
                                        </div>
                                    </ui:repeat>
                                    <ui:fragment rendered="#{mdb.id == '1'}">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">
                                                #{bundle['dataset.metadata.publicationYear']}
                                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataset.metadata.publicationYear.tip']}"></span>
                                            </label>
                                            <div class="col-sm-6">
                                                <p:inputText id="dvFieldNamez" styleClass="form-control" value="#{AdvancedSearchPage.dsPublicationDate}"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">
                                                #{bundle['dataset.metadata.persistentId']}
                                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataset.metadata.persistentId.tip']}"></span>
                                            </label>
                                            <div class="col-sm-6">
                                                <p:inputText id="dsPersistentIdentifier" styleClass="form-control" value="#{AdvancedSearchPage.dsPersistentId}"/>
                                            </div>
                                        </div>
                                    </ui:fragment>
                                </div>
                            </div>
                        </ui:repeat>

                        <div class="panel panel-default">
                            <div data-toggle="collapse" data-target="#panelCollapseFilesFieldList" class="panel-heading">
                                <h:outputText value="#{bundle['advanced.search.header.files']}"/> &#160;<span class="glyphicon glyphicon-chevron-up"/>
                            </div>
                            <div id="panelCollapseFilesFieldList" class="panel-body form-horizontal collapse in">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        #{bundle.name}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['advanced.search.files.name.tip']}"></span>
                                    </label>
                                    <div class="col-sm-6">
                                        <p:inputText id="fileFieldName" styleClass="form-control" value="#{AdvancedSearchPage.fileFieldName}"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        #{bundle.description}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['advanced.search.files.description.tip']}"></span>
                                    </label>
                                    <div class="col-sm-6">
                                        <p:inputText id="fileFieldDescription" styleClass="form-control" value="#{AdvancedSearchPage.fileFieldDescription}"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        #{bundle['advanced.search.files.fileType']}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['advanced.search.files.fileType.tip']}"></span>
                                    </label>
                                    <div class="col-sm-6">
                                        <p:inputText id="fileFieldFiletype" styleClass="form-control" value="#{AdvancedSearchPage.fileFieldFiletype}"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        #{bundle['advanced.search.files.persistentId']}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['advanced.search.files.persistentId.tip']}"></span>
                                    </label>
                                    <div class="col-sm-6">
                                        <p:inputText id="fileFieldPersistentId" styleClass="form-control" value="#{AdvancedSearchPage.filePersistentId}"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        #{bundle['advanced.search.files.variableName']}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['advanced.search.files.variableName.tip']}"></span>
                                    </label>
                                    <div class="col-sm-6">
                                        <p:inputText id="fileFieldVariableName" styleClass="form-control" value="#{AdvancedSearchPage.fileFieldVariableName}"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        #{bundle['advanced.search.files.variableLabel']}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['advanced.search.files.variableLabel.tip']}"></span>
                                    </label>
                                    <div class="col-sm-6">
                                        <p:inputText id="fileFieldVariableLabel" styleClass="form-control" value="#{AdvancedSearchPage.fileFieldVariableLabel}"/>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.find}" action="#{AdvancedSearchPage.find()}"/>
                        </div>
                    </h:form>
                </div>
            </ui:define>
        </ui:composition>
    </h:body>
</html>
